package com.gopay.common.domain.pg;

import java.math.BigDecimal;
import java.sql.Clob;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.gopay.common.constants.trans.UserType;

/**
 * Entity: 网关P2P订单流水表
 */
@Entity
@Table(name = "PG_GSRT_ORDER_TRANS_DTL")
public class PgGsrtOrderTransDtl implements java.io.Serializable {
    
    /**
     * 
     * @Description: 对外客户类型 01 个人 ； 02企业,   对内10 个人 ； 20企业
     * @author hougn
     * @date 2016年3月31日 下午8:51:55 
     *
     */
    public enum UserTypeGsrt {
        personal("01", UserType.Person.value, "个人"), enterprise("02", UserType.CorpManager.value, "企业");

        /**
         * 对外
         */
        private String external;
        /**
         * 对内
         */
        private String inside;
        private String name;

        private UserTypeGsrt(String external, String inside, String name) {
            this.external = external;
            this.inside = inside;
            this.name = name;
        }

        public String getExternal() {
            return external;
        }

        public String getInside() {
            return inside;
        }

        public String getName() {
            return name;
        }

        /**
         * 外转内
         * @param external
         * @return
         */
        public static String external2inside(String external) {
            if (external == null) {
                return null;
            }
            for (UserTypeGsrt flag : UserTypeGsrt.values()) {
                if (flag.getExternal().equals(external)) {
                    return flag.inside;
                }
            }
            return null;
        }
        
        /**
         * 内转外
         * @param inside
         * @return
         */
        public static String inside2external(String inside) {
            if (inside == null) {
                return null;
            }
            for (UserTypeGsrt flag : UserTypeGsrt.values()) {
                if (flag.getInside().equals(inside)) {
                    return flag.external;
                }
            }
            return null;
        }
    }

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /** 
    * 交易流水号
    */
    private Long transDtlSq;

    /** 
     * 商户编号
     */
    private String merId;

    /** 
     * 商户订单号
     */
    private String merOrderId;
    /** 
     * 原商户订单号 针对查询交易
     */
    private String orgMerOrderId;

    /** 
     * 商户接口交易码
     */
    private String merTxnCd;

    /** 
     * 商户交易时间
     */
    private Date merTxnTm;

    /** 
     * 国付宝交易时间
     */
    private Date gopayTxnTm;

    /** 
     * 订单国付宝服务器时间戳
     */
    private Date gopayServerTime;

    /** 
     * 网关通道
    00 - 未经网关
    01 - 直连银行
    02 - 网关收银台
    03 - 网关接口
    
     */
    private String gatewayChannel;

    /** 
     * 网关版本号
     */
    private String gatewayVersion;

    /** 
     * 字符集1 GBK 2 UTF-8
     */
    private String charset;

    /** 
     * 语言 1 ZH 2 EN 暂不使用
     */
    private String language;

    /** 
     * 签名算法类型 1 MD5 2 SHA
     */
    private String signType;

    /** 
     * 订单处理响应码
    0000-交易成功
    4444-交易失败
    9999-交易处理中
    
     */
    private String rspCode;

    /** 
     * 协议号
     */
    private String contractNo;

    /** 
     * GS01签约；GS02充值；GS03提现；GS04发标；GS05标的更新；GS06投标；GS07流标；GS08放款；GS09还款；GS10回款；GS11转账；GS12账户查询；GS13业务查询；
    GS14标的查询;GS15充提转查询；GS16签约查询；
     */
    private String tranCmd;

    /** 
     * 收款人信息,最大1000人
    （格式：协议号:金额;协议号:金额）
    
     */
    private Clob recvInfo;

    /** 
     * 付款人信息（格式：协议号:金额）
    或风险金账户
     */
    private String payInfo;

    /** 
     * 标号
     */
    private String bid;

    /** 
     * 手续费
     */
    private BigDecimal comAmt;

    /** 
     * 佣金承担方
    (协议号)
     */
    private String comPayer;

    /** 
     * 手续费承担方
    (协议号或平台托管账户)
     */
    private String feePayer;

    /** 
     * 币种
    156-人民币
    
     */
    private String curType;

    /** 
     * 商户交易金额
     */
    private BigDecimal merTxnAmt;

    /** 
     * 订单是否允许重复提交，0不允许 1允许默认允许旧网关无此字段默认允许
     */
    private String legalOrderRepaet;

    /** 
     * 通知外部系统状态（商户）
    0 通知成功
    1 未通知
    2 通知失败
    
     */
    private String merNotifyStat;

    /** 
     * 交易发起IP
     */
    private String transLaunchIp;

    /** 
     * 请求refer地址
     */
    private String reqRefer;

    /** 
     * 系统备注
     */
    private String sysRemark;

    /** 
     * 商户交易结果页面通知URL
     */
    private String merNotifyFrontUrl;

    /** 
     * 商户交易结果服务器通知URL
     */
    private String merNotifyServerUrl;

    /** 
     * 创建时间
     */
    private Date createdTs;

    /** 
     * 记录最后修改时间
     */
    private Date lastUpdTs;

    /** 
     * 最后修改交易码
     */
    private String lastUpdTrancode;

    /** 
     * 商户备注信息1
     */
    private String merRemark1;

    /** 
     * 商户备注信息2
     */
    private String merRemark2;

    /** 
     * 商户备注信息3
     */
    private String merRemark3;

    /** 
     * 商户备注信息4
     */
    private String merRemark4;

    /** 
     * 商户备注信息5
     */
    private String merRemark5;

    /** 
     * 用户姓名
     */
    private String custName;

    /** 
     * 证件号码
     */
    private String certNo;

    /** 
     * 企业名称
     */
    private String corpName;

    /**
     * 证件类型
     */
    private String certType;

    /** 
     * 标的名称
     */
    private String bidName;

    /** 
     * 标的产品类型
     */
    private String bidType;

    /** 
     * 利率（年化）
     */
    private String interest;

    /** 
     * 借款期限
     */
    private String loanLife;

    /** 
     * 借款期限单位
     */
    private String loanLifeUnit;

    /** 
     * 还款日期
     */
    private Date repaymentDay;

    /** 
     * 投标类型     01：网贷专用账户投标  /还款方式    01：一次性还本付息、02：先息后本、03：等额本息、04：等额本金、05、众筹无还款 06:其他/
     */
    private String repaymentType;

    /** 
     * 客户类型 01 个人 ； 02企业
     */
    private String userType;

    /** 
     * 募集中创建时间/还款中创建时间/结束创建时间/解约时间
     */
    private Date collectCreatedTs;

    /** 
     * 分账信息子表
     */
    private Clob ledgerAccount;

    /** 
     * 回款人信息子表
     */
    private Clob returnedMoney;

    /** 
     * 用户支付金额/
     */
    private BigDecimal userTxnAmt;

    /** 
     * 平台支付金额
     */
    private BigDecimal thirdpartyTxnAmt;

    /** 
     * 转账模式    转账模式-----01:【网贷平台账户】转【网贷风险金账户】02:【网贷平台账户】转【网贷专用账户】03：【网贷平台账户】转【网贷担保方账户】
     */
    private String transferMode;
    /**
     * 标的状态
     */
    private String bidState;

    /**
     * 网关来源
     */
    private String gatewaySource;
    /**
     * 交易失败原因
     */
    private String commentRk;
    /**
     * 用户 来源  way  pc
     */
    private String userSource;
    
    /**
     * wap签约： userName 手机号码
     */
    private String userName;
    /**
     * 手机终端    01:ios ;02: Android
     */
    private String mobileTerminal;

    //add by songfengli 20160927
    private String remoteIp;

    public PgGsrtOrderTransDtl() {
    }

    @Id
    @SequenceGenerator(name = "PgGsrtOrderTransDtlSequence", sequenceName = "PG_GSRT_ORDER_TRANS_DTL_SEQ")
    @GeneratedValue(generator = "PgGsrtOrderTransDtlSequence", strategy = GenerationType.SEQUENCE)
    @Column(name = "TRANS_DTL_SQ", unique = true, nullable = false, precision = 22, scale = 0)
    public Long getTransDtlSq() {
        return this.transDtlSq;
    }

    public void setTransDtlSq(Long transDtlSq) {
        this.transDtlSq = transDtlSq;
    }

    @Column(name = "MER_ID", nullable = false, length = 10)
    public String getMerId() {
        return this.merId;
    }

    public void setMerId(String merId) {
        this.merId = merId;
    }

    @Column(name = "MER_ORDER_ID", nullable = false, length = 30)
    public String getMerOrderId() {
        return this.merOrderId;
    }

    public void setMerOrderId(String merOrderId) {
        this.merOrderId = merOrderId;
    }

    @Column(name = "ORG_MER_ORDER_ID", length = 30)
    public String getOrgMerOrderId() {
        return orgMerOrderId;
    }

    public void setOrgMerOrderId(String orgMerOrderId) {
        this.orgMerOrderId = orgMerOrderId;
    }

    @Column(name = "MER_TXN_CD", nullable = false, length = 10)
    public String getMerTxnCd() {
        return this.merTxnCd;
    }

    public void setMerTxnCd(String merTxnCd) {
        this.merTxnCd = merTxnCd;
    }

    @Column(name = "MER_TXN_TM", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getMerTxnTm() {
        return this.merTxnTm;
    }

    public void setMerTxnTm(Date merTxnTm) {
        this.merTxnTm = merTxnTm;
    }

    @Column(name = "GOPAY_TXN_TM", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getGopayTxnTm() {
        return this.gopayTxnTm;
    }

    public void setGopayTxnTm(Date gopayTxnTm) {
        this.gopayTxnTm = gopayTxnTm;
    }

    @Column(name = "GOPAY_SERVER_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getGopayServerTime() {
        return this.gopayServerTime;
    }

    public void setGopayServerTime(Date gopayServerTime) {
        this.gopayServerTime = gopayServerTime;
    }

    @Column(name = "GATEWAY_CHANNEL", nullable = false, length = 2)
    public String getGatewayChannel() {
        return this.gatewayChannel;
    }

    public void setGatewayChannel(String gatewayChannel) {
        this.gatewayChannel = gatewayChannel;
    }

    @Column(name = "GATEWAY_VERSION", nullable = false, length = 5)
    public String getGatewayVersion() {
        return this.gatewayVersion;
    }

    public void setGatewayVersion(String gatewayVersion) {
        this.gatewayVersion = gatewayVersion;
    }

    @Column(name = "CHARSET", length = 1)
    public String getCharset() {
        return this.charset;
    }

    public void setCharset(String charset) {
        this.charset = charset;
    }

    @Column(name = "LANGUAGE", length = 1)
    public String getLanguage() {
        return this.language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    @Column(name = "SIGN_TYPE", length = 1)
    public String getSignType() {
        return this.signType;
    }

    public void setSignType(String signType) {
        this.signType = signType;
    }

    @Column(name = "RSP_CODE", nullable = false, length = 4)
    public String getRspCode() {
        return this.rspCode;
    }

    public void setRspCode(String rspCode) {
        this.rspCode = rspCode;
    }

    @Column(name = "CONTRACT_NO", length = 20)
    public String getContractNo() {
        return this.contractNo;
    }

    public void setContractNo(String contractNo) {
        this.contractNo = contractNo;
    }

    @Column(name = "TRAN_CMD", length = 8)
    public String getTranCmd() {
        return this.tranCmd;
    }

    public void setTranCmd(String tranCmd) {
        this.tranCmd = tranCmd;
    }

    @Column(name = "RECV_INFO")
    public Clob getRecvInfo() {
        return this.recvInfo;
    }

    public void setRecvInfo(Clob recvInfo) {
        this.recvInfo = recvInfo;
    }

    @Column(name = "PAY_INFO", length = 50)
    public String getPayInfo() {
        return this.payInfo;
    }

    public void setPayInfo(String payInfo) {
        this.payInfo = payInfo;
    }

    @Column(name = "BID", length = 30)
    public String getBid() {
        return this.bid;
    }

    public void setBid(String bid) {
        this.bid = bid;
    }

    @Column(name = "COM_AMT", precision = 20)
    public BigDecimal getComAmt() {
        return this.comAmt;
    }

    public void setComAmt(BigDecimal comAmt) {
        this.comAmt = comAmt;
    }

    @Column(name = "COM_PAYER", length = 20)
    public String getComPayer() {
        return this.comPayer;
    }

    public void setComPayer(String comPayer) {
        this.comPayer = comPayer;
    }

    @Column(name = "FEE_PAYER", length = 20)
    public String getFeePayer() {
        return this.feePayer;
    }

    public void setFeePayer(String feePayer) {
        this.feePayer = feePayer;
    }

    @Column(name = "CUR_TYPE", length = 3)
    public String getCurType() {
        return this.curType;
    }

    public void setCurType(String curType) {
        this.curType = curType;
    }

    @Column(name = "MER_TXN_AMT", precision = 20)
    public BigDecimal getMerTxnAmt() {
        return this.merTxnAmt;
    }

    public void setMerTxnAmt(BigDecimal merTxnAmt) {
        this.merTxnAmt = merTxnAmt;
    }

    @Column(name = "LEGAL_ORDER_REPAET", length = 1)
    public String getLegalOrderRepaet() {
        return this.legalOrderRepaet;
    }

    public void setLegalOrderRepaet(String legalOrderRepaet) {
        this.legalOrderRepaet = legalOrderRepaet;
    }

    @Column(name = "MER_NOTIFY_STAT", length = 1)
    public String getMerNotifyStat() {
        return this.merNotifyStat;
    }

    public void setMerNotifyStat(String merNotifyStat) {
        this.merNotifyStat = merNotifyStat;
    }

    @Column(name = "TRANS_LAUNCH_IP", nullable = false, length = 50)
    public String getTransLaunchIp() {
        return this.transLaunchIp;
    }

    public void setTransLaunchIp(String transLaunchIp) {
        this.transLaunchIp = transLaunchIp;
    }

    @Column(name = "REQ_REFER", length = 1000)
    public String getReqRefer() {
        return this.reqRefer;
    }

    public void setReqRefer(String reqRefer) {
        this.reqRefer = reqRefer;
    }

    @Column(name = "SYS_REMARK", length = 200)
    public String getSysRemark() {
        return this.sysRemark;
    }

    public void setSysRemark(String sysRemark) {
        this.sysRemark = sysRemark;
    }

    @Column(name = "MER_NOTIFY_FRONT_URL", length = 500)
    public String getMerNotifyFrontUrl() {
        return this.merNotifyFrontUrl;
    }

    public void setMerNotifyFrontUrl(String merNotifyFrontUrl) {
        this.merNotifyFrontUrl = merNotifyFrontUrl;
    }

    @Column(name = "MER_NOTIFY_SERVER_URL", length = 500)
    public String getMerNotifyServerUrl() {
        return this.merNotifyServerUrl;
    }

    public void setMerNotifyServerUrl(String merNotifyServerUrl) {
        this.merNotifyServerUrl = merNotifyServerUrl;
    }

    @Column(name = "CREATED_TS", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getCreatedTs() {
        return this.createdTs;
    }

    public void setCreatedTs(Date createdTs) {
        this.createdTs = createdTs;
    }

    @Column(name = "LAST_UPD_TS", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getLastUpdTs() {
        return this.lastUpdTs;
    }

    public void setLastUpdTs(Date lastUpdTs) {
        this.lastUpdTs = lastUpdTs;
    }

    @Column(name = "LAST_UPD_TRANCODE", length = 6)
    public String getLastUpdTrancode() {
        return this.lastUpdTrancode;
    }

    public void setLastUpdTrancode(String lastUpdTrancode) {
        this.lastUpdTrancode = lastUpdTrancode;
    }

    @Column(name = "MER_REMARK1", length = 500)
    public String getMerRemark1() {
        return this.merRemark1;
    }

    public void setMerRemark1(String merRemark1) {
        this.merRemark1 = merRemark1;
    }

    @Column(name = "MER_REMARK2", length = 500)
    public String getMerRemark2() {
        return this.merRemark2;
    }

    public void setMerRemark2(String merRemark2) {
        this.merRemark2 = merRemark2;
    }

    @Column(name = "MER_REMARK3", length = 500)
    public String getMerRemark3() {
        return this.merRemark3;
    }

    public void setMerRemark3(String merRemark3) {
        this.merRemark3 = merRemark3;
    }

    @Column(name = "MER_REMARK4", length = 500)
    public String getMerRemark4() {
        return this.merRemark4;
    }

    public void setMerRemark4(String merRemark4) {
        this.merRemark4 = merRemark4;
    }

    @Column(name = "MER_REMARK5", length = 500)
    public String getMerRemark5() {
        return this.merRemark5;
    }

    public void setMerRemark5(String merRemark5) {
        this.merRemark5 = merRemark5;
    }

    @Column(name = "CERT_NO", length = 30)
    public String getCertNo() {
        return this.certNo;
    }

    public void setCertNo(String certNo) {
        this.certNo = certNo;
    }

    @Column(name = "BID_NAME", length = 50)
    public String getBidName() {
        return this.bidName;
    }

    public void setBidName(String bidName) {
        this.bidName = bidName;
    }

    @Column(name = "BID_TYPE", length = 50)
    public String getBidType() {
        return this.bidType;
    }

    public void setBidType(String bidType) {
        this.bidType = bidType;
    }

    @Column(name = "INTEREST", length = 50)
    public String getInterest() {
        return this.interest;
    }

    public void setInterest(String interest) {
        this.interest = interest;
    }

    @Column(name = "LOAN_LIFE", length = 50)
    public String getLoanLife() {
        return this.loanLife;
    }

    public void setLoanLife(String loanLife) {
        this.loanLife = loanLife;
    }

    @Column(name = "LOAN_LIFE_UNIT")
    public String getLoanLifeUnit() {
		return loanLifeUnit;
	}

	public void setLoanLifeUnit(String loanLifeUnit) {
		this.loanLifeUnit = loanLifeUnit;
	}

    @Column(name = "REPAYMENT_DAY")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getRepaymentDay() {
        return this.repaymentDay;
    }

    public void setRepaymentDay(Date repaymentDay) {
        this.repaymentDay = repaymentDay;
    }

    @Column(name = "REPAYMENT_TYPE", length = 50)
    public String getRepaymentType() {
        return this.repaymentType;
    }

    public void setRepaymentType(String repaymentType) {
        this.repaymentType = repaymentType;
    }

    @Column(name = "USER_TYPE", length = 50)
    public String getUserType() {
        return this.userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    @Column(name = "COLLECT_CREATED_TS")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getCollectCreatedTs() {
        return this.collectCreatedTs;
    }

    public void setCollectCreatedTs(Date collectCreatedTs) {
        this.collectCreatedTs = collectCreatedTs;
    }

    @Column(name = "LEDGER_ACCOUNT")
    public Clob getLedgerAccount() {
        return this.ledgerAccount;
    }

    public void setLedgerAccount(Clob ledgerAccount) {
        this.ledgerAccount = ledgerAccount;
    }

    @Column(name = "RETURNED_MONEY")
    public Clob getReturnedMoney() {
        return this.returnedMoney;
    }

    public void setReturnedMoney(Clob returnedMoney) {
        this.returnedMoney = returnedMoney;
    }

    @Column(name = "USER_TXN_AMT", precision = 20)
    public BigDecimal getUserTxnAmt() {
        return this.userTxnAmt;
    }

    public void setUserTxnAmt(BigDecimal userTxnAmt) {
        this.userTxnAmt = userTxnAmt;
    }

    @Column(name = "THIRDPARTY_TXN_AMT", precision = 20)
    public BigDecimal getThirdpartyTxnAmt() {
        return this.thirdpartyTxnAmt;
    }

    public void setThirdpartyTxnAmt(BigDecimal thirdpartyTxnAmt) {
        this.thirdpartyTxnAmt = thirdpartyTxnAmt;
    }

    @Column(name = "TRANSFER_MODE", length = 50)
    public String getTransferMode() {
        return this.transferMode;
    }

    public void setTransferMode(String transferMode) {
        this.transferMode = transferMode;
    }

    @Column(name = "BID_STATE", length = 50)
    public String getBidState() {
        return bidState;
    }

    public void setBidState(String bidState) {
        this.bidState = bidState;
    }

    @Column(name = "CUST_NAME", length = 50)
    public String getCustName() {
        return custName;
    }

    public void setCustName(String custName) {
        this.custName = custName;
    }

    @Column(name = "CERT_TYPE", length = 2)
    public String getCertType() {
        return certType;
    }

    public void setCertType(String certType) {
        this.certType = certType;
    }

    @Column(name = "CORP_NAME", length = 100)
    public String getCorpName() {
        return corpName;
    }

    public void setCorpName(String corpName) {
        this.corpName = corpName;
    }


    @Column(name = "GATEWAY_SOURCE", length = 2)
    public String getGatewaySource() {
		return gatewaySource;
	}

	public void setGatewaySource(String gatewaySource) {
		this.gatewaySource = gatewaySource;
	}

	@Column(name = "COMMENT_RK", length = 50)
    public String getCommentRk() {
        return this.commentRk;
    }

    public void setCommentRk(String commentRk) {
        this.commentRk = commentRk;
    }
    @Column(name = "USER_SOURCE", length = 8)
    public String getUserSource() {
		return userSource;
	}

	public void setUserSource(String userSource) {
		this.userSource = userSource;
	}
    
	@Column(name = "USER_NAME", length = 50)
    public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	@Column(name = "MOBILE_TERMINAL", length = 4)
	public String getMobileTerminal() {
		return mobileTerminal;
	}

	public void setMobileTerminal(String mobileTerminal) {
		this.mobileTerminal = mobileTerminal;
	}

	@Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
    }

    @Column(name = "REMOTE_IP",length = 40)
    public String getRemoteIp() {
        return remoteIp;
    }

    public void setRemoteIp(String remoteIp) {
        this.remoteIp = remoteIp;
    }

}
